home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / BARNET / COMPILER / SATHER / !Sather / Library / Containrs / config / array next >
Text File  |  1996-08-20  |  7KB  |  141 lines

  1. #ifndef ARRAY_CONFIG
  2. #define ARRAY_CONFIG
  3.  
  4. #ifdef PP
  5. #undef PP
  6. #endif
  7.  
  8. #define PP    no_pre,no_post
  9.  
  10. ARRAY_SIZE:            PP,reads "@0::asize",var "@r $$;",
  11.                 exec "$$=($0)==NULL?0:ASIZE(@(0)$0);" "$$",
  12.                 f_exec "$$=FVOID($0)?0:^0?ASIZE(@(0)$0):F_ASIZE(@0,$0);" "$$";
  13. ARRAY_CLEAR:            PP,writes "@0::[],@0::asize",
  14.                 exec "if($0!=NULL) AREFACLEAR($0);",
  15.                 f_exec "if(!FVOID($0)) { if(^0) AREFACLEAR($0); else F_AREFACLEAR_A(@0,$0); }";
  16. ARRAY_COPY:            PP,reads "@0::[]" "@0::asize",writes "@0::[]" "@0::asize",
  17.                 exec "if($0!=NULL && $1!=NULL) AREFACOPY($0,$1);",
  18.                 f_exec "if(!FVOID($0) && !FVOID($1)) { if(^0 && ^1) AREFACOPY($0,$1); else F_AREFACOPY_AA(@0,@P0,$0,$1); }";
  19. ARRAY_COPY_BEG:            PP,reads "@0::[]" "@0::asize",writes "@0::[]" "@0::asize",
  20.                 exec "if($2!=NULL) AREFACOPYB($0,$1,$2);",
  21.                 f_exec "if(!FVOID($2)) { if(^0 && ^1) AREFACOPYB($0,$1,$2); else F_AREFACOPYB_AA(@0,@P0,$0,$1,$2); }";
  22. ARRAY_COPY_BEG_NUM:        PP,reads "@0::[]" "@0::asize",writes "@0::[]" "@0::asize",
  23.                 exec "AREFACOPYBN($0,$1,$2,$3);",
  24.                 f_exec "if(^0 && ^1) AREFACOPYBN($0,$1,$2,$3); else F_AREFACOPYBN_AA(@0,@P0,$0,$1,$2,$3);";
  25. ARRAY_COPY_BEG_NUM_SRCBEG:    PP,reads "@0::[]" "@0::asize",writes "@0::[]" "@0::asize",
  26.                 exec "AREFACOPYBNS($0,$1,$2,$3,$4);",
  27.                 f_exec "F_AREFACOPYBNS_AA(@0,@P0,$0,$1,$2,$3,$4);";
  28.  
  29. ARRAY_ELTB:            reads     "@0::[]" "@0::asize",
  30.                 attr_access 1,
  31.                 var     "INT $$br;",
  32.                 init     "$$br=$0==NULL?0:ASIZE(@(0)$0);",
  33.                 break     "$$br",
  34.                 temp     "@r a$$;",
  35.                 iter     "a$$=ARR(@(0)$0,$#);" "a$$",
  36.                 f_init     "$$br=FVOID($0)?0:^0?ASIZE(@(0)$0):F_ASIZE(@0,$0);",
  37.                 f_iter  "#if %r==0" "if(^0) a$$=ARR(@(0)$0,$#); else F_R_RARR_NA(a$$,@0,$0,$#);" 
  38.                         "#elif %r==1" "if(^0) a$$=ARR(@(0)$0,$#); else F_VA_RARR_NA(a$$,@0,$0,$#);" 
  39.                         "#elif %r==2" "if(^0) VASS_LP(a$$,@r,ARR(@(0)$0,$#)); else F_V_RARR_LP(@r,a$$,@0,$0,$#);" 
  40.                            "#endif"
  41.                            "a$$";
  42. ARRAY_ELT_BEGB:            reads     "@0::[]" "@0::asize",
  43.                 var      "INT $$c,$$s;",
  44.                 attr_access 1,
  45.                 temp     "@r a$$;",
  46.                 init     "$$c=$1-1;$$s=$0==0?0:ASIZE(@(0)$0);",
  47.                 f_init     "$$c=$1-1;$$s=FVOID($0)?0:^0?ASIZE(@(0)$0):F_ASIZE(@0,$0);",
  48.                 iter     "if(++$$c>=$$s) @@;"
  49.                          "a$$=ARR(@(0)$0,$$c);" "a$$",
  50.                 f_iter     "if(++$$c>=$$s) @@;"
  51.                         "#if %r==0" "if(^0) a$$=ARR(@(0)$0,$$c); else F_R_RARR_NA(a$$,@0,$0,$$c);" 
  52.                         "#elif %r==1" "if(^0) a$$=ARR(@(0)$0,$$c); else F_VA_RARR_NA(a$$,@0,$0,$$c);" 
  53.                         "#elif %r==2" "if(^0) VASS_LP(a$$,@r,ARR(@(0)$0,$#)); else F_V_RARR_LP(@r,a$$,@0,$0,$#);" 
  54.                          "#endif"
  55.                          "a$$";
  56. ARRAY_ELT_BEG_NUMB:        reads     "@0::[]" "@0::asize",
  57.                 var      "INT $$c,$$m;",
  58.                 temp     "@r a$$;",
  59.                 attr_access 1,
  60.                 init     "$$c=$1-1;$$m=$1+$2;",
  61.                 iter     "if(++$$c>=$$m) @@;"
  62.                          "a$$=ARR(@(0)$0,$$c);" "a$$",
  63.                 f_iter     "if(++$$c>=$$m) @@;"
  64.                         "#if %r==0" "if(^0) a$$=ARR(@(0)$0,$$c); else F_R_RARR_NA(a$$,@0,$0,$$c);" 
  65.                         "#elif %r==1" "if(^0) a$$=ARR(@(0)$0,$$c); else F_VA_RARR_NA(a$$,@0,$0,$$c);" 
  66.                         "#elif %r==2" "if(^0) VASS_LP(a$$,@r,ARR(@(0)$0,$#)); else F_V_RARR_LP(@r,a$$,@0,$0,$#);" 
  67.                          "#endif" 
  68.                          "a$$";
  69. ARRAY_ELT_BEG_NUM_STEPB:    reads     "@0::[]" "@0::asize",
  70.                 var      "INT $$c,$$m;",
  71.                 attr_access 1,
  72.                 temp     "@r a$$;",
  73.                 init     "$$c=$1;$$m=$1+$2*$3;",
  74.                 iter     "if($3>=0&&$$c>=$$m||$3<0&&$$c<=$$m)@@;"
  75.                          "a$$=ARR(@(0)$0,$$c);" "$$c+=$3;" "a$$",
  76.                 f_iter     "if($$c>=$$m) @@;"
  77.                         "#if %r==0" "if(^0) a$$=ARR(@(0)$0,$$c); else F_R_RARR_NA(a$$,@0,$0,$$c);" 
  78.                         "#elif %r==1" "if(^0) a$$=ARR(@(0)$0,$$c); else F_VA_RARR_NA(a$$,@0,$0,$$c);" 
  79.                         "#elif %r==2" "if(^0) VASS_LP(a$$,@r,ARR(@(0)$0,$#)); else F_V_RARR_LP(@r,a$$,@0,$0,$#);" 
  80.                          "#endif" 
  81.                          "$$c+=$3;" "a$$";
  82. ARRAY_SETB:            writes     "@0::[]",
  83.                 attr_access 1,
  84.                 reads     "@0::asize",
  85.                 var     "INT $$br;",
  86.                 init     "$$br=$0==NULL?0:ASIZE(@(0)$0);",
  87.                 f_init     "$$br=FVOID($0)?0:^0?ASIZE(@(0)$0):F_ASIZE(@0,$0);",
  88.                 break     "$$br",
  89.                 iter     "SARR(@(0)$0,$#,@(1)$1);",
  90.                 f_iter  "#if %1==0" "if(^0) SARR(@(0)$0,$#,@(1)$1); else F_R_WARR_NA(@0,$0,$#,$1);" 
  91.                         "#elif %1==1" "if(^0) SARR(@(0)$0,$#,@(1)$1); else F_VA_WARR_NA(@0,$0,$#,$1);" 
  92.                         "#elif %1==2" "if(^0) { CHK_BOUNDS($#,0,ASIZE($0)-1,0);VASS_PP((@(0)$0)->arr_part[$#],@1,$1);} else F_V_WARR_LP(@0,$0,$#,@1,$1);" 
  93.                     "#endif";
  94. ARRAY_SET_BEGB:            writes  "@0::[]",
  95.                 attr_access 1,
  96.                 reads   "@0::asize",
  97.                 var     "INT $$c,$$s;",
  98.                 init    "$$c=$1-1;$$s=$0==NULL?0:ASIZE(@(0)$0);",
  99.                 f_init  "$$c=$1-1;$$s=FVOID($0)?0:^0?ASIZE(@(0)$0):F_ASIZE(@0,$0);",
  100.                 iter    "if(++$$c>=$$s) @@;"
  101.                         "SARR(@(0)$0,$$c,@(2)$2);",
  102.                 f_iter  "if(++$$c>=$$s) @@;"
  103.                         "#if %2==0" "if(^0) SARR(@(0)$0,$$c,@(2)$2); else F_R_WARR_NA(@0,$0,$$c,$2);" 
  104.                         "#elif %2==1" "if(^0) SARR(@(0)$0,$$c,@(2)$2); else F_VA_WARR_NA(@0,$0,$$c,$2);" 
  105.                         "#elif %2==2" "if(^0) { CHK_BOUNDS($$c,0,ASIZE($0)-1,0);VASS_PP((@(0)$0)->arr_part[$$c],@2,$2);} else F_V_WARR_LP(@0,$0,$$c,@2,$2);" 
  106.                         "#endif";
  107. ARRAY_SET_BEG_NUMB:        writes  "@0::[]",
  108.                 attr_access 1,
  109.                 reads   "@0::asize",
  110.                 var     "INT $$c,$$m;",
  111.                 init    "$$c=$1-1;$$m=$1+$2;",
  112.                 iter    "if(++$$c>=$$m) @@;"
  113.                         "SARR(@(0)$0,$$c,@(3)$3);",
  114.                 f_iter  "if(++$$c>=$$m) @@;"
  115.                         "#if %3==0" "if(^0) SARR(@(0)$0,$$c,@(1)$3); else F_R_WARR_NA(@0,$0,$$c,$3);" 
  116.                         "#elif %3==1" "if(^0) SARR(@(0)$0,$$c,@(1)$3); else F_VA_WARR_NA(@0,$0,$$c,$3);" 
  117.                         "#elif %3==2" "if(^0) { CHK_BOUNDS($$c,0,ASIZE($0)-1,0);VASS_PP((@(0)$0)->arr_part[$$c],@3,$3);} else F_V_WARR_LP(@0,$0,$$c,@3,$3);" 
  118.                         "#endif";
  119. ARRAY_SET_BEG_NUM_STEPB:    reads   "@0::[]",
  120.                 attr_access 1,
  121.                 writes  "@0::asize",
  122.                 var     "INT $$c,$$m;",
  123.                 init    "$$c=$1;$$m=$1+$2*$3;",
  124.                 iter    "if($3>=0&&$$c>=$$m||$3<0&&$$c<=$$m)@@;"
  125.                         "SARR(@(0)$0,$$c,@(4)$4);" "$$c+=$3;",
  126.                 f_iter  "if($$c>=$$m) @@;"
  127.                         "#if %4==0" "if(^0) SARR(@(0)$0,$$c,@(1)$4); else F_R_WARR_NA(@0,$0,$$c,$4);" 
  128.                         "#elif %4==1" "if(^0) SARR(@(0)$0,$$c,@(1)$4); else F_VA_WARR_NA(@0,$0,$$c,$4);" 
  129.                         "#elif %4==2" "if(^0) { CHK_BOUNDS($$c,0,ASIZE($0)-1,0);VASS_PP((@(0)$0)->arr_part[$$c],@4,$4);} else F_V_WARR_LP(@0,$0,$$c,@4,$4);" 
  130.                         "#endif" 
  131.                         "$$c+=$3;";
  132. ARRAY_INDB:            reads     "@0::asize",
  133.                 var     "INT $$br;",
  134.                 init     "$$br=$0==NULL?0:ASIZE(@(0)$0);",
  135.                 f_init     "$$br=FVOID($0)?0:^0?ASIZE(@(0)$0):F_ASIZE(@0,$0);",
  136.                 break     "$$br",
  137.                 temp     "@r r$$;",
  138.                 iter     "r$$=$#;" "r$$";
  139.  
  140. #endif
  141.